<?php $paginator = $this->Paginator; ?>
<div class="row-fluid">
    <div class="span12">
        <?php echo $this->element('message'); ?>   
        <div class="page-header">
            <h1>Transactions History</h1>
        </div>
        <table class="table table-bordered table-striped">
        <!-- <table class="datagrid"> -->
            <thead>
                <tr>
                    <th><?php echo $paginator->sort('id', 'ID') ?></th>
                    <th><?php echo $paginator->sort('date_added', 'date') ?></th>                    
                    <th><?php echo $paginator->sort('payment', 'Payment') ?></th>                    
                    <th>Name</th>
                    <th>Email</th>                    
                    <th>Amount</th>                    
                    <th>Status</th>
                    <th colspan="2">Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($rows as $row) {
                    $rd_id = rand(1000000000, 9999999999);                    
                    echo "<tr>";
                    echo "<td>{$row['Transaction']['id']}</td>";
                    echo "<td>{$row['Transaction']['date_paid']}</td>";
                    echo "<td>{$row['Transaction']['payment']}</td>";
                    echo "<td>".$row['User']['lastname']. " ". $row['User']['middlename'] ." ". $row['User']['firstname']."</td>";
                    echo "<td>{$row['User']['email']}</td>";
                    echo "<td>".$row['Transaction']['amount']." ".$row['Transaction']['currency']."</td>";
                    echo "<td>{$row['Transaction']['payment_status']}</td>";
                    echo "<td>{$this->Html->link(__('View'), array('action' => 'view', $row['Transaction']['id']), array('class' => 'btn btn-info'))}</td>";
                    echo "<td><form action=\"{$this->Html->url('delete/' . $row['Transaction']['id'])}\" name=\"post_{$rd_id}\" id=\"post_{$rd_id}\" style=\"display:none;\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"POST\"></form>{$this->Html->link(__('Delete'), '#', array('class' => 'btn btn-danger', 'onclick' => 'if (confirm( \'Are you sure you want to delete #' . $row["Transaction"]["id"] . '\')) {document.post_' . $rd_id . '.submit(); } event.returnValue = false; return false;'))}</td>";
                    echo "</tr>";
                }
                ?>
            </tbody>
        </table>

        <div class="pagination">
            <ul>
                <?php
                echo '<li>' . $paginator->first("First") . '</li>';
                if ($paginator->hasPrev()) {
                    echo '<li>' . $paginator->prev("Prev") . '</li>';
                }
                // the 'number' page buttons
                echo $paginator->numbers(array('modulus' => 3, 'tag' => 'li', 'separator' => '', 'currentTag' => 'a', 'currentClass' => 'active'));

                // for the 'next' button
                if ($paginator->hasNext()) {
                    echo '<li>' . $paginator->next("Next") . '</li>';
                }
                // the 'last' page button
                echo '<li>' . $paginator->last("Last") . '</li>';
                ?>
            </ul>
        </div>
    </div>
</div>
